<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<!-- saved from url=(0014)about:internet -->
<head>
    <title>Qdb.Silverlight.TestStart</title>

	<style type="text/css">
		p.normal { font-family: Verdana  }		
		p.success { color: Green }		
		p.failure { color: Red }		
		p.exception { font-family: Verdana; border: thin dashed #FF6600; background-color: #FFFFCC; color: #800000 }
		
    html, body {
	    height: 100%;
	    overflow: auto;
    }
    body {
	    padding: 0;
	    margin: 0;
    }
    #silverlightControlHost {
	    height: 100%;
    }
    	#TextArea1
		{
			height: 273px;
			width: 863px;
		}
		#Result
		{
			height: 292px;
		}
    </style>
    
    <script type="text/javascript">
    	function onSilverlightError(sender, args) {
    		var appSource = "";
    		if (sender != null && sender != 0) {
    			appSource = sender.getHost().Source;
    		}
    		var errorType = args.ErrorType;
    		var iErrorCode = args.ErrorCode;

    		var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";

    		errMsg += "Code: " + iErrorCode + "    \n";
    		errMsg += "Category: " + errorType + "       \n";
    		errMsg += "Message: " + args.ErrorMessage + "     \n";

    		if (errorType == "ParserError") {
    			errMsg += "File: " + args.xamlFile + "     \n";
    			errMsg += "Line: " + args.lineNumber + "     \n";
    			errMsg += "Position: " + args.charPosition + "     \n";
    		}
    		else if (errorType == "RuntimeError") {
    			if (args.lineNumber != 0) {
    				errMsg += "Line: " + args.lineNumber + "     \n";
    				errMsg += "Position: " + args.charPosition + "     \n";
    			}
    			errMsg += "MethodName: " + args.methodName + "     \n";
    		}

    		throw new Error(errMsg);
    	}

	</script>
</head>

<body>
	<div style="border-style: groove; border-width: medium; background-color: #FFFFCC; position: fixed; top: 40px; right: 40px; font-family: Verdana; width: 100px; height: 80px;"> 
		Total: <div id="Total">0</div>
		Errors: <div id="Errors">0</div>
	</div>	
    <!-- Runtime errors from Silverlight will be displayed here.
	This will contain debugging information and should be removed or hidden when debugging is completed -->
	<div id='errorLocation' style="font-size: small;color: Gray;"></div>	
	</div>
	
    <div id="silverlightControlHost">
		<div id="result" style="width: 100%; height: auto; margin-bottom: 41px; font-family: Verdana;"/>
			
		<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
			<param name="source" value="Qdb.Silverlight.TestStart.xap"/>
			<param name="onerror" value="onSilverlightError" />
			<param name="background" value="white" />
			<param name="minRuntimeVersion" value="3.0.40307.0" />
			<param name="autoUpgrade" value="true" />
			<param name="EnableHtmlAccess" value="1" />
			<a href="http://go.microsoft.com/fwlink/?LinkID=141205" style="text-decoration: none;">
     			<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
			</a>
		</object>
		<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
    </div>
	<p id="para">&nbsp;</p>	
	<script language='javascript'>
		var resultObject = document.getElementById('result');
		var total = document.getElementById("Total");
		var errors = document.getElementById("Errors");
		var errorCount = 0;
		var testCount = 0;
		var currentId = 0;

		function getErrorCount() {
			return errorCount;
		}
		
		function updateTestInfo() {
			errors.innerHTML = errorCount + "";
			total.innerHTML = testCount + "";
		}

		function newTest(message) {
			testCount++;
			updateTestInfo();
			return appendInternal(testCount + ") " + message, "normal");
		}

		function append(message) {
			return appendInternal(message, "normal");
		}

		function appendError(index, result) {
			errorCount++;
			updateTestInfo();
			return appendInternal(index + ") " + result, "failure");
		}

		function appendException(exception) {
			return appendInternal(exception, "exception");
		}

		function appendTestsResult(elapsedTimeInSeconds) {
			return appendInternal(
					testResultMessageFor(testCount, errorCount, elapsedTimeInSeconds),
					classFor(errorCount));
		}

		function testResultMessageFor(testCount, errorCount, elapsedTimeInSeconds) {
			var msg = testCount + " tests";
			if (errorCount > 0) {
				msg = errorCount + " tests failed out of " + testCount;
			}

			return statusMessageFor(errorCount) + ": " + msg + " in " + elapsedTimeInSeconds + " seconds";
		}

		function successfullCount(testCount, errorCount) {
			return testCount - errorCount;
		}

		function statusMessageFor(errorCount) {
			return errorCount == 0 ? "SUCCEEDED" : "FAILED";
		}

		function classFor(errorCount) {
			return errorCount > 0 ? "failure" : "success";
		}

		function appendInternal(result, className) {
			var newParagraph = document.createElement("p");
			var id = className + "_" + ++currentId;

			newParagraph.setAttribute("id", id);
			newParagraph.className = className;
			newParagraph.innerHTML = escapeHTML(result);

			resultObject.appendChild(newParagraph);
			resultObject.scrollIntoView(false);

			return id;
		}

		function markAsFailure(id) {
			errorCount++;
			updateTestInfo();

			document.getElementById(id).className = "failure";
		}

		function escapeHTML(toEscape) {
			return toEscape.replace(/</, "&lt").replace(/>/, "&gt");
		}

		function completed() {
			var completedElement = document.createElement("div");
			completedElement.setAttribute("id", "completed");
			document.appendChild(completedElement);
		}
	</script>
</body>
</html>
